<?php

return [
    'http' => [
        'enable' => true,
        'host' => '0.0.0.0',
        'port' => env('SWOOLE.PORT', 9084),
        'worker_num' => swoole_cpu_num() * 2,
        'options' => [
            'package_max_length' => 20 * 1024 * 1024,
            'buffer_output_size' => 10 * 1024 * 1024,
            'socket_buffer_size' => 128 * 1024 * 1024,
            'open_tcp_nodelay' => true,
            'open_cpu_affinity' => true,
            'max_request' => env('SWOOLE.MAX_REQUEST', 3000),
            'task_max_request' => 2000,
            'open_tcp_keepalive' => true, // 启用 TCP keepalive
            'tcp_keepidle' => 600, // 保持连接的时间，单位为秒
            'tcp_keepinterval' => 60, // 发送探测包的时间间隔，单位为秒
        ],
    ],
    'websocket' => [
        'enable' => true,
        'handler' => \think\swoole\websocket\Handler::class,
        'ping_interval' => 25000,
        'ping_timeout' => 60000,
        'room' => [
            'type' => 'table',
            'table' => [
                'room_rows' => 8192,
                'room_size' => 2048,
                'client_rows' => 4096,
                'client_size' => 2048,
            ],
            'redis' => [
                'host' => '127.0.0.1',
                'port' => 6379,
                'max_active' => 3,
                'max_wait_time' => 5,
            ],
        ],
        'listen' => [],
        'subscribe' => [
            \app\subscribe\WebSocketEvent::class
        ],
    ],
    'rpc' => [
        'server' => [
            'enable' => false,
            'host' => '0.0.0.0',
            'port' => 9000,
            'worker_num' => swoole_cpu_num(),
            'services' => [],
        ],
        'client' => [],
    ],
    //队列
    'queue' => [
        'enable' => true,
        'workers' => [
            //下面参数是不设置时的默认配置
            env('queue.queue_name', 'default') => [
                'delay' => 0,
                'sleep' => 1,
                'tries' => 0,
                'timeout' => 60,
                'worker_num' => 1,
            ],
        ],
    ],
    'hot_update' => [
        'enable' => env('APP_DEBUG', false),
        'name' => ['*.php'],
        'include' => [app_path(), root_path() . 'route', root_path() . 'extend', root_path() . 'config'],
        'exclude' => [],
    ],
    //连接池
    'pool' => [
        'db' => [
            'enable' => true,
            'max_active' => 3,
            'max_wait_time' => 5,
        ],
        'cache' => [
            'enable' => true,
            'max_active' => 3,
            'max_wait_time' => 5,
        ],
        //自定义连接池
    ],
    'ipc' => [
        'type' => 'unix_socket',
        'redis' => [
            'host' => '127.0.0.1',
            'port' => 6379,
            'max_active' => 3,
            'max_wait_time' => 5,
        ],
    ],
    'tables' => [
        'u2fd' => [
            'size' => 102400,
            'columns' => [
                ['name' => 'fd', 'type' => \Swoole\Table::TYPE_STRING, 'size' => 50]
            ]
        ],
        'fd2u' => [
            'size' => 102400,
            'columns' => [
                ['name' => 'type', 'type' => \Swoole\Table::TYPE_STRING, 'size' => 50],
                ['name' => 'uid', 'type' => \Swoole\Table::TYPE_INT],
                ['name' => 'items_id', 'type' => \Swoole\Table::TYPE_INT],
            ]
        ],
    ],
    //每个worker里需要预加载以共用的实例
    'concretes' => [],
    //重置器
    'resetters' => [],
    //每次请求前需要清空的实例
    'instances' => [],
    //每次请求前需要重新执行的服务
    'services' => [],
];
